_Pragma("once")

#include <unistd.h>

#include "INetwork.h"
#include  "BasicDevice.h"
#include "HalUtility.h"
#include "SerialPortCommunicator.h"
#include "ErrorCode.h"



class Lte4gNetwork : public INetwork {
public:
    /** Default constructor */
    Lte4gNetwork(const std::string& name = "ppp0") : mnetworkCardController(GENERAL_CONTROL_FILE) {
        this->mname = name;
        this->mtype = NetworkType::IOT_4G;

        getRealCardFile(mcardFile);
    }
    /** Default destructor */
    virtual ~Lte4gNetwork();

     bool running() override {
         int returnCode = ::access(mcardFile.data(), F_OK);
//        std::string message{"Lte4gNetwork::running"};
//        LOG_DEDUG(buildErrorMessage(returnCode, errno, message).data());
        return !returnCode;
    }


     void start() override;

     void stopHardware() override;
     void startHardware() override;


     std::string getSignalStrength()override;

protected:

    std::string& getRealCardFile(std::string& result);

    BasicDevice mnetworkCardController;

    std::string mcardFile;

    static const std::string SIGNAL_FUNCTION_TIP;

    static constexpr char REQUEST_SIGNAL[] = "AT+CSQ\r";
    static constexpr char SIGNAL_ACK_PREFIX[] = "+CSQ:";
};
